const common = reuire('./common.js');

/**
 * 定义用户
 * @param {*} app 
 */
module.exports = app => {
  const {INTEGER, STRING } = app.Sequelize;
  return app
    .model
    .define('user', {
      id: {
        type: INTEGER,
        primaryKey: true,
        autoIncrement: true
      },
      app_id: {
        type: STRING,
        comment: '应用ID'
      },
      third_id: {
        type: STRING,
        comment: '关联用户ID'
      },
      avatar: {
        type: STRING,
        comment: '用户头像'
      },
      nickname: {
        type: STRING,
        comment: '用户昵称'
      },
      ...common
    }, {
      timestamps: false,
      freezeTableName: true,
      tableName: 't_user',
      underscored: true
    }
  );
};